-include ../../common.mk
-include ../../common.mk
CHARMINC=../../../include
CHARMBIN=../../../bin
CHARMC=../../../bin/charmc $(OPTS)

OBJS=megatest.o \
     groupring.o \
     nodering.o \
     varsizetest.o \
     varsizetest2.o \
     varraystest.o \
     groupcast.o \
     groupmulti.o \
     groupsectiontest.o \
     multisectiontest.o \
     nodecast.o \
     synctest.o \
     fib.o \
     arrayring.o \
     packtest.o \
     queens.o \
     migration.o \
     marshall.o \
     priomsg.o \
     priotest.o \
     rotest.o \
     statistics.o \
     templates.o \
     inherit.o \
     reduction.o \
     bitvector.o \
     immediatering.o \
     callback.o \
     inlineem.o \
     completion_test.o \
     groupdependence.o \
     listsend.o

CIFILES =  \
      arrayring.def.h  immediatering.def.h  nodering.def.h   rotest.def.h  \
      bitvector.def.h  inherit.def.h        packtest.def.h   synctest.def.h  \
      callback.def.h   marshall.def.h       priomsg.def.h    templates.def.h \
      fib.def.h        megatest.def.h       priotest.def.h   \
      groupcast.def.h  migration.def.h      queens.def.h     varraystest.def.h\
      groupring.def.h  nodecast.def.h       reduction.def.h  varsizetest.def.h\
      groupsectiontest.def.h multisectiontest.def.h inlineem.def.h varsizetest2.def.h\
      groupmulti.def.h completion_test.def.h groupdependence.def.h listsend.def.h

.SUFFIXES:
.SUFFIXES: .o .C .def.h .decl.h .ci .h

all: megatest

megatest: $(OBJS)
	$(CHARMC) -o megatest  $(OBJS) -language charm++ -module completion

.ci.decl.h:
	$(CHARMC) -c $<

.decl.h.def.h:
	@true

DEPENDFILE = Make.depends

include $(DEPENDFILE)

clean:
	rm -r -f conv-host megatest megatest.exe megatest.pdb megatest.ilk *.o *.decl.h *.def.h *.log *.sts *~ *.bak charmrun SunWS_cache

test: megatest
	$(call run, ./megatest +p1 )
	$(call run, ./megatest +p2 )
	$(call run, ./megatest +p3 )
	$(call run, ./megatest +p4 )

testp: megatest
	$(call run, ./megatest +p$(P) )

smptest: megatest
	$(call run, ./megatest +p2 ++ppn 2 )
	$(call run, ./megatest +p4 ++ppn 2 )

depends:  $(CIFILES)
	echo "Creating " $(DEPENDFILE) " ...";	\
        if [ -f $(DEPENDFILE) ]; then \
           /bin/cp -f $(DEPENDFILE) $(DEPENDFILE).old; \
        fi; \
        echo '#generated by make depends' > $(DEPENDFILE); \
        for i in $(OBJS) ; do \
              SRCFILE=`basename $$i .o`.C ; \
              echo "checking dependencies for $$SRCFILE" ; \
              g++ -std=c++0x -MM -I$(CHARMINC) $$SRCFILE | \
              perl $(CHARMBIN)/dep.pl $(CHARMINC) /usr/include /usr/local >> $(DEPENDFILE); \
              echo '	$$(CHARMC) -o '$$i $$SRCFILE >> $(DEPENDFILE) ; \
        done;
